$(function() {
	query('01'); //第一次加载
	$("#search").click(function() {
		query('01');
	});
});

function query(type) {	
	$.ajax({
		url: hTtp + "personRepresent/queryPersonRepresentList.action",
		data: {
			pageNo: $("#pageNo").val(),
			keyword: $('.search').val(),
			types:0
		},
		type: 'post',
		cache: false,
		success: function(data) {
			loading = true;
			var data = data.personRepresentList;
			if(data == null) {
				$("#pageNo").val(parseInt($("#pageNo").val()) - 1);
			} else {
				var test = "";
				if(type == "00") {
					if(data.length == 0) {
						alert("1111");
						$("#pageNo").val(parseInt($("#pageNo").val()) - 1);
						//$(".list").append('<a class="pull-right blue" href="listdetails.html">查看详情</a>');
						return "";
					}
					for(var i = 0; i < data.length; i++) {
						test += '<li class="padding">'
						test += '	<h3 class="text-auto padding-bottom padding-top"><a href="listdetails.html" class="blue">' + data[i].title + '</a></h3>'
						test += '	<div class="list-box text-auto padding-top padding-bottom text-muted">' + data[i].content + '</div>'
						test += '	<div class="clear">'
						test += '		<div class="pull-left">' + data[i].createTime + '</div>'
						test += '		<a class="pull-right blue" href="listdetails.html?id=' + data[i].id + '">查看详情</a>'
						test += '	</div>'
						test += '</li>'
					}
					$(".list").append(test);
					$(".dropload-load").hide();
					$(".dropload-noData").show();
				} else {
					for(var i = 0; i < data.length; i++) {
						test += '<li class="padding">'
						test += '	<h3 class="text-auto padding-bottom padding-top"><a href="listdetails.html" class="blue">' + data[i].title + '</a></h3>'
						test += '	<div class="list-box text-auto padding-top padding-bottom text-muted">' + data[i].content + '</div>'
						test += '	<div class="clear">'
						test += '		<div class="pull-left">' + data[i].createTime + '</div>'
						test += '		<a class="pull-right blue" href="listdetails.html?id=' + data[i].id + '">查看详情</a>'
						test += '	</div>'
						test += '</li>'
					}
					$(".list").html(test);
					$(".dropload-load").show();
					$(".dropload-noData").hide();
				}
			}
		},
		error: function() {
			loading = true;
			$("#pageNo").val(parseInt($("#pageNo").val()) - 1);
			_alert("查询数据出错啦，请刷新再试");
		}
	});
}
var loading = false;
Zepto(function($) {
	$(window).scroll(function() {
		if(($(window).scrollTop() + $(window).height() > $(document).height() - 5) && loading) {
			$(".dropload-load").show();
			loading = false;
			$("#pageNo").val(parseInt($("#pageNo").val()) + 1);
			query("00");
		}
	});
})